package service

import (
	"GIN-API/internal/models"
	"GIN-API/internal/repository"
)

// ChannelService 定义频道服务层结构体
type ChannelService struct {
	channelRepo *repository.ChannelRepository
}

// NewChannelService 创建频道服务层实例
func NewChannelService(channelRepo *repository.ChannelRepository) *ChannelService {
	return &ChannelService{
		channelRepo: channelRepo,
	}
}

// CreateChannel 创建频道
func (cs *ChannelService) CreateChannel(channel *models.Channel) error {
	return cs.channelRepo.CreateChannel(channel)
}

// GetChannelByID 根据频道 ID 获取频道信息
func (cs *ChannelService) GetChannelByID(id uint) (*models.Channel, error) {
	return cs.channelRepo.GetChannelByID(id)
}

// UpdateChannel 更新频道信息
func (cs *ChannelService) UpdateChannel(channel *models.Channel) error {
	return cs.channelRepo.UpdateChannel(channel)
}

// DeleteChannel 根据频道 ID 删除频道
func (cs *ChannelService) DeleteChannel(id uint) error {
	return cs.channelRepo.DeleteChannel(id)
}

// GetAllChannels 获取所有频道
func (cs *ChannelService) GetAllChannels() ([]*models.Channel, error) {
	return cs.channelRepo.GetAllChannels()
}
